<?PHP

global $config,$root_path, $core,$user,$document,$result;
if($_GET["debug"]){
error_reporting(E_ALL);
ini_set('display_errors', '1');
}
$config=(object)array();

include_once 'config/defaults.config.php';
include_once 'config/paths.config.php';
include_once 'config/db.config.php';

include_once $config->paths["core"]."pay_core.php";


    $result["error"]="1";
    $result["errorDescription"]="Error desconocido";




$app=$_POST["app"]?$_POST["app"]:$_GET["app"];
$task=trim($_POST["task"]?$_POST["task"]:$_GET["task"],"/");

switch($app){
  default:
    $handler=$core->getHandler($app);
	  if($handler){
	  	$handler->run($task);
	  }
	  else {
	    $result["error"]="2";
	    $result["errorDescription"]="Aplicacion Desconocida";
	  }
    break;
}

$lexicon=$core->getLexicon();


if($lexicon){
	$result["errorDescription"]=$lexicon->traduce($result["errorDescription"]);
}
switch($_GET["output"]){
	case "xml":
		header("content-type:text/xml");
		$app=$core->getApp("xmlconvert");
		$respuesta=&$app->convertArray($result);
		echo $respuesta->asXML();
		break;
	default:
		header("content-type:text/javascript");
		echo $_GET["callback"]."(".json_encode($result).",'".($_POST["idcallback"]?$_POST["idcallback"]:$_GET["idcallback"])."');";

}


?>